## ------------------------------------------------------------------------------------------------------- #
## Replication Data for:
## Wawro, Gregory, and Ira Katznelson. 
## Time Counts: Quantitative Analysis for Historical Social Science. Princeton University Press, 2022.
##
## Release Date:  	June 2, 2022
## Contact Information: 	Gregory Wawro <gjw10@columbia.edu>  
## ------------------------------------------------------------------------------------------------------- #

## --------------------------------- #
## Computer Recommendation
## --------------------------------- #

All scripts were replicated on a MacBook Pro (15-inch, 2019), running macOS Monterey (12.2.1).


## --------------------------------- #
## R Version 
## --------------------------------- #

All scripts were replicated in the following R version:

	R version 4.0.4 (2021-02-15)	Copyright (C) 2021 The R Foundation for Statistical Computing	Platform: x86_64-apple-darwin17.0 (64-bit)

All scripts were executed in RStudio with the following version:

	RStudio 2022.02.2+485 "Prairie Trillium" 
	Release (8acbd38b0d4ca3c86c570cf4112a8180c48cc6fb, 2022-04-19) for macOS
	Mozilla/5.0 (Macintosh; Intel Mac OS X 12_2_1) AppleWebKit/537.36 (KHTML, like Gecko) 
	QtWebEngine/5.12.10 Chrome/69.0.3497.128 Safari/537.36


## --------------------------------- #
## R and R Packages 
## --------------------------------- #

The scripts make use of the folder structure. Set the working directory to the folder containing the 
code:
	
	setwd("PATH_NAME/Replication/Code")

where PATH_NAME is the path to the parent Replication folder.

The scripts make use of the following R packages (PackageName_Version): 

VGAM_1.1-5           forcats_0.5.1        stringr_1.4.0        purrr_0.3.4          readr_2.1.2         tidyr_1.1.4          tibble_3.1.6         tidyverse_1.3.1      strucchange_1.5-2    sandwich_3.0-0      zoo_1.8-8            spdep_1.1-11         sf_1.0-2             spData_2.0.1         sp_1.4-5            shinystan_2.5.0      shiny_1.6.0          rstan_2.21.5         StanHeaders_2.21.0-7 reshape2_1.4.4      R2BayesX_1.1-1.1     mgcv_1.8-33          nlme_3.1-152         colorspace_2.0-3     BayesXsrc_3.0-2     plyr_1.8.6           plm_2.4-0            coda_0.19-4          haven_2.4.3          MASS_7.3-53    gridExtra_2.3        gplots_3.1.1         ggplot2_3.3.5        dplyr_1.0.7          cmdstanr_0.4.0.9000 bcp_4.0.3            BayesX_0.3-1         shapefiles_0.7       foreign_0.8-81       arm_1.11-2          lme4_1.1-27.1        Matrix_1.3-2              
## --------------------------------- #
## Stan 
## --------------------------------- #

All stan models are executed in R with the following R packages:

rstan   (Version 2.21.2, GitRev: 2e1f913d3ca3)
cmdstan (Version 2.29.2)


## --------------------------------- #
## MCMCpack Version Discrepancies 
## --------------------------------- #

Figure 4.6 was produced with an R package MCMCpack version 1.2-2
(2012-03-03). After publication of the book, we tried using a recent
version of MCMCpack (e.g., version 1.6-2), which resulted in posterior
probabilities that differ from those reported in the book and would
lead to very different inferences.  We suspect this may be due to a
package update in the function testpanelSubjectBreak(). Earlier
versions (e.g., version 1.3-1 or earlier) generate results similar to
those reported in the book. We are exploring this issue further.


## --------------------------------- #
## Folder Directory
## --------------------------------- #

To replicate results, we suggest creating the following directory
tree. Alternatively, you can download time_counts.tar.gz and extract
the directories and files with the command 'tar -xvf  time_counts.tar.gz'.

Replication
	⊢ _README.txt
	⊢ _Codebook.xlsx		Data dictionary for the raw data used in the analyses
	⊢ Data 			Contains the data sets used for analyses in the book
	⊢ Output			Contains results of model estimates
	⊢ Code			Contains .R scripts used to produce tables and figures
        |	⊢ Macros		Contains .R scripts that serve as helper functions for analyses (bias_plot.R, change_point.R,
		  			plot_rhos.R, rescale.R, rw_matrix.R)
        |	∟ Stan		Contains .stan scripts called by .R scripts (bias_plot.R, change_point.R, plot_rhos.R, rescale.R, rw_matrix.R)
	⊢ Figures 		Contains the figures included in the book 
	∟ Tables			Contains the tables included in the book 

The names of the files containing the main R code correspond to the figure
and/or table numbers where the results are reported in the book.


 
